define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'pro/coursebase/index',
                    add_url: 'pro/coursebase/add',
                    edit_url: 'pro/coursebase/edit',
                    del_url: 'pro/coursebase/del',
                    multi_url: 'pro/coursebase/multi',
                    table: 'gzns_course',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'category_id', title: __('Category_id')},
                        {field: 'name', title: __('Name')},
                        {field: 'sort', title: __('Sort')},
                        {field: 'cover', title: __('Cover')},
                        {field: 'summary', title: __('Summary')},
                        {field: 'price', title: __('Price'), operate:'BETWEEN'},
                        {field: 'status', title: __('Status')},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'type', title: __('Type')},
                        {field: 'column', title: __('Column')},
                        {field: 'address', title: __('Address')},
                        {field: 'time', title: __('Time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'lat', title: __('Lat')},
                        {field: 'lng', title: __('Lng')},
                        {field: 'short_address', title: __('Short_address')},
                        {field: 'mail', title: __('Mail')},
                        {field: 'phone', title: __('Phone')},
                        {field: 'teacher_id', title: __('Teacher_id')},
                        {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'people_limit', title: __('People_limit')},
                        {field: 'comment_count', title: __('Comment_count')},
                        {field: 'buy_count', title: __('Buy_count')},
                        {field: 'wx_card_id', title: __('Wx_card_id')},
                        {field: 'is_ticket', title: __('Is_ticket')},
                        {field: 'ticket_title', title: __('Ticket_title')},
                        {field: 'is_recommend', title: __('Is_recommend')},
                        {field: 'is_home', title: __('Is_home')},
                        {field: 'is_notice', title: __('Is_notice')},
                        {field: 'wjx_status', title: __('Wjx_status')},
                        {field: 'wjx_id', title: __('Wjx_id')},
                        {field: 'history_content', title: __('History_content')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});